package io.github.l86400.core.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author 86400
 * @since 2021/12/21 17:12
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SystemException extends RuntimeException {
    private String code;
    private String showMessage;

    public SystemException(ExceptionEnum exceptionEnum, Throwable cause) {
        this(exceptionEnum.getCode(), exceptionEnum.getMessage(), exceptionEnum.getShowMessage(), cause);
    }

    public SystemException(ExceptionEnum exceptionEnum) {
        this(exceptionEnum.getCode(), exceptionEnum.getMessage(), exceptionEnum.getShowMessage());
    }

    public SystemException(ExceptionEnum exceptionEnum, String messageAppend) {
        this(exceptionEnum.getCode(), exceptionEnum.getMessage(), exceptionEnum.getShowMessage());
    }

    public SystemException(String code, String message) {
        super(message);
        this.code = code;
    }

    public SystemException(String code, String message, String showMessage) {
        super(message);
        this.code = code;
        this.showMessage = showMessage;
    }

    public SystemException(String code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public SystemException(String code, String message, String showMessage, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.showMessage = showMessage;
    }
}
